/*
 * Main.java
 *
 * Created on April 21, 2007, 6:03 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package usyd.comp5348;

import java.util.Properties;
import javax.ejb.EJB;
import javax.naming.InitialContext;

/**
 *
 * @author david
 */
public class Main {
    
//    @EJB(name="Customer", mappedName="corbaname:iiop:jerodael:3700#Customer")
//    private static CustomerRemote cr;
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws Exception {
        try {
//        InitialContext ic = new InitialContext();
//        Object o = ic.lookup("corbaname:iiop:129.78.9.214:3700#ejb/Customer");
        
        Properties env1 = new Properties();
//        env1.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
//        env1.setProperty("java.naming.provider.url", "iiop://192.168.1.10:3700");
//        env1.setProperty("java.naming.factory.url.pkgs","com.sun.enterprise.naming");
//        env1.setProperty("java.naming.factory.state","com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
        env1.setProperty("org.omg.CORBA.ORBInitialHost","192.168.1.10");
        env1.setProperty("org.omg.CORBA.ORBInitialPort","3700");
        
        Properties props = new Properties();
        props.setProperty(InitialContext.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
        props.setProperty("java.naming.provider.url", "iiop://192.168.1.10:3700");
        InitialContext ic1 = new InitialContext( env1 );
//        InitialContext ic1 = new InitialContext(props);
/*        InitialContext context = new InitialContext();
        context.addToEnvironment("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
        context.addToEnvironment("java.naming.provider.url", "iiop://129.78.9.214:3700");
        context.addToEnvironment("java.naming.factory.url.pkgs","com.sun.enterprise.naming");
        context.addToEnvironment("java.naming.factory.state","com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
        context.addToEnvironment("org.omg.CORBA.ORBInitialHost","129.78.9.214");
        context.addToEnvironment("org.omg.CORBA.ORBInitialPort","3700");*/
        
//        CustomerRemote cr2 = (CustomerRemote)context.lookup("corbaname:iiop:jerodael:3700#ejb/Customer");
//        CatalogueRemote cr2 = (CatalogueRemote)context.lookup("Catalogue");
        System.err.println("HERE");
        CustomerRemote cr2 = (CustomerRemote)ic1.lookup("ejb/Customer");
        System.err.println("HERE");
        
        cr2.deleteCustomer(1);
        
/*        InitialContext ic2 = new InitialContext();
        ic2.addToEnvironment("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
        ic2.addToEnvironment("java.naming.provider.url", "iiop://jerodael:3700");
        ic2.addToEnvironment("java.naming.factory.url.pkgs","com.sun.enterprise.naming");
        ic2.addToEnvironment("java.naming.factory.state","com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
        ic2.addToEnvironment("org.omg.CORBA.ORBInitialHost","jerodael");
        ic2.addToEnvironment("org.omg.CORBA.ORBInitialPort","3700");
        CustomerRemote cr3 = (CustomerRemote)ic2.lookup("ejb/Customer");*/
        
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
}
